
<head>
  <link rel="shortcut icon" href="/images/pagepig.ico" />

  <link href="/css/theme-plugin.css" rel="stylesheet" />
  <link href="/css/theme.min.css" rel="stylesheet" />
  <link href="/css/bootstrap.min.css" rel="stylesheet">

</head>

<div class="page-content">
<section>
  <div class="container">
    <div class="row mb-4 align-items-center">
      <div class="col-md-5 mb-3 mb-md-0"> <span class="text-muted" id="goodsTotal"></span></div>
    </div>
    <!--商品div-->
    <div class="row" id="goodsList">
      <div class="col-lg-3 col-md-6 mb-5">
        <div class="card product-card card--default rounded-0">

        </div>
      </div>
    </div>
  </div>
  <!--分页DIV-->
    <div class="row" id="fenye">

    </div>
</section>
</div>

<!--footer start-->
<footer class="py-11 bg-dark-1">
  <div class="container">
    <div class="row">
      <div class="col-12 col-lg-4"> <a class="footer-logo text-white h2 mb-0" href="index.html"> <img class="img-fluid" src="/images/logo001.png" alt=""> </a>

      </div>
      <div class="col-12 col-lg-8 mt-6 mt-lg-0">
        <h5 style="color: white;">佩奇牧场，专注于提供高品质肉类生产及行业解决方案，通过创新技术引领现代农业革新，为中国消费者提供安全、美味的优质食品。</h5>
      </div>
    </div>
    <div class="row pt-9">
      <div class="col-lg-4 col-md-6 col-sm-12">
        <div class="d-flex footer-box">
          <div class="mr-4"> <i class="las la-map-marker-alt ic-2x icon-img"></i> </div>
          <div>
            <h6 class="mb-1 text-white font-w-5">公司地址</h6>
            <p class="mb-0 font-w-4 text-muted">广东省珠海市</p>
            <p class="mb-0 font-w-4 text-muted">香洲区国贸大厦88楼 佩奇牧场</p>
          </div>
        </div>
      </div>
      <div class="col-lg-4 col-md-6 col-sm-12">
        <div class="d-flex footer-box">
          <div class="mr-4"> <i class="las la-envelope ic-2x icon-img"></i> </div>
          <div>
            <h6 class="mb-1 text-white font-w-5">联系邮箱</h6>
            <p class="mb-0 font-w-4 text-muted" href="mailto:themeht23@gmail.com"> pagepigmc@gmail.com</p>
            <p class="mb-0 font-w-4 text-muted" href="mailto:themeht23@gmail.com"> pqmc@gmail.com</p>
          </div>
        </div>
      </div>
      <div class="col-lg-4 col-md-6 col-sm-12">
        <div class="d-flex footer-box">
          <div class="mr-4"> <i class="las la-mobile ic-2x icon-img"></i> </div>
          <div>
            <h6 class="mb-1 text-white font-w-5">联系我们</h6>
            <p class="mb-0 font-w-4 text-muted">24/7客服</p>
            <p class="mb-0 font-w-4 text-muted">+400 888 2333 </p>
          </div>
        </div>
      </div>
    </div>
    <div >
      <br><br />
      <div style="text-align: center;color: white;"><small>Copyright ©&copy; 2020 佩奇牧场  pqmc.xyz All Rights Reserved</small> </div>
    </div>
  </div>
</footer>
<!--footer end-->

<script src="/js/jquery-3.5.1.min.js"></script> <script src="/js/popper.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/owl.carousel.min.js"></script>
<script src="/js/light-slider.js"></script>
<script src="/js/parallax.js"></script>
<script src="/js/magnific-popup.min.js"></script>
<script src="/js/jquery.countdown.min.js"></script>
<script src="/js/jquery.dd.min.js"></script>
<script src="/js/validator.js"></script>
<script src="/js/wow.js"></script>
<script src="/js/theme-script.js"></script>

<script>
  $(function () {
    $("#fenye").load("/page/fenye",function () {
        getObject();
    })
  });

  function getObject() {
    $("#goodsList").empty();
    //获取是否存在绑定数据
    let pageCurrent =$("#goodsTotal").data("pageCurrent");
    //不存在则认为页面是第一次加载
    if (pageCurrent === undefined) {
      pageCurrent = 1;
    }
    let categoryId = $(".page-wrapper").data("categoryId");
    console.log(categoryId);
    //TODO 添加商品名字
    let title = "";
    $.ajax({
      url:"/goods/doFindAllGoods",
      type:"GET",
      data:{
        "title":title,
        "categoryId":categoryId,
        "pageCurrent":pageCurrent,
        "status":1
      },
      success:(result)=>{
        if (result.status === 200) {

          let records = result.data.goodsRecords;
          //创建商品表格
          creatDiv(records);
          //计算显示数据条数
          let showGoods = result.data.pageCurrent*result.data.pageSize;
          //获取总条数
          let rowCount = result.data.rowCount;
          if (showGoods > rowCount) {
            showGoods = rowCount;
          }
          let str = "共"+rowCount+"条数据,已显示"+showGoods+"条数据";
          $(".pageCurrent").html("第"+pageCurrent+"页");
          $("#goodsTotal").data("pageCurrent",pageCurrent).data("pageCount",result.data.pageCount).html(str);
        }else{
          $("#goodsList").append("<span style='text-align: center'>"+result.message+"</span>");
        }
      }
    });
  }

  function creatDiv(records) {
    for (let i = 0; i < records.length; i++) {
      let data = records[i];
      let imgArr = data.img.split(",");
      let str = "<div class='col-lg-3 col-md-6 mb-5'>"+
              "<div class='card product-card card--default rounded-0'>"+
              "<a class='card-img-hover d-block' href='/page/jumpGoods/"+data.id+"'>"+
              "<img class='card-img-back' src='"+imgArr[0]+"' alt='...'>"+
              "<img class='card-img-front' src='"+imgArr[1]+"' alt='...'>" +
              "</a>"+
              "<div class='card-info'>" +
              "<div class='card-body'>"+
              "<div class='product-title font-w-5'>" +
              "<a class='link-title'>"+data.title+"</a>" +
              "</div>" +
              "<div class='mt-1'>"+
              "<span class='product-price text-pink'>"+data.price+"</span>" +
              "<div class='star-rating'>" +
              "<i class='las la-star'></i><i class='las la-star'></i><i class='las la-star'></i><i class='las la-star'></i><i class='las la-star'></i></div></div></div>"+
              "<div class='card-footer bg-transparent border-0'>"+
              "<div class='product-link d-flex align-items-center justify-content-center'>"+
              "<button class='btn-cart btn btn-pink mx-3' type='button'>"+
              "<i class='las la-shopping-cart mr-1'></i> 添加购物车</button></div></div></div>";
      $("#goodsList").append(str);
    }
  }

</script>